// "封装" : 把该藏的藏起来、把该露的露出来

function LunarCalendar() {

    // 在构造函数内部声明的局部变量是不对实例公开的，可以认为是"私有数据"
    let heavenlyStems = ['甲', '乙', '丙', '丁', '戊', '己', '庚', '辛', '壬', '癸'];
    let earthlyBranches = ['子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申', '酉', '戌', '亥'];

    // 在构造函数内部使用 this 绑定的属性是可以暴露给实例的
    this.showYears = function() {
        let s = '';
        for (let i = 0; i < 60; i++) {
            let h = i % heavenlyStems.length;
            let e = i % earthlyBranches.length;
            let hs = heavenlyStems[h];
            let eb = earthlyBranches[e];
            let he = hs + eb;
            s = s + he + (e == 11 ? '\n' : '\t');
        }
        return s;
    }

}

let lc = new LunarCalendar();
console.log('LunarCalendar instance : ', lc);
console.log(LunarCalendar.heavenlyStems); //undefined
console.log(lc.heavenlyStems); //undefined
let s = lc.showYears();
console.log(s);